imcontextwayland: Honour len argument in gtk_im_context_wayland_set_surrounding
authorRobert Mader <robert.mader@posteo.de>
Mon, 16 Mar 2020 15:53:18 +0000 (16:53 +0100)
committerRobert Mader <robert.mader@posteo.de>
Mon, 16 Mar 2020 15:53:33 +0000 (16:53 +0100)
Clients may pass not `NULL`-terminated strings as the function takes a
`len` argument. Use that argument.

gtk/gtkimcontextwayland.c

index 393f9b91c6782c3cdaf3d55d553f3b33cf2c215d..2462f7201fd36b0a6492f54fd73c331a5e24d596 100644 (file)
@@ -860,7 +860,7 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
   context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
 
   g_free (context_wayland->surrounding.text);
-  context_wayland->surrounding.text = g_strdup (text);
+  context_wayland->surrounding.text = g_strndup (text, len);
   context_wayland->surrounding.cursor_idx = cursor_index;
   /* Anchor is not exposed via the set_surrounding interface, emulating. */
   context_wayland->surrounding.anchor_idx = cursor_index;